alert("Thanks for using" && the title of gScriptOMaticWindow && "! Email your feature ideas to <ideas@gmatter.com>...")
set gScriptOMaticDefaultFormatTable to VOID
set gScriptOMaticCurrentFormatTable to VOID
set gScriptOMaticMasterColorTable to VOID
set gScriptOMaticObject to VOID
set gScriptOMaticDemo to VOID
set gScriptOMaticUsageCount to VOID
set gScriptOMaticVersion to VOID
set gScriptOMaticPreview to VOID
set gScriptOMaticZoomOut to VOID
set gScriptOMaticDebug to VOID
set gScriptOMaticElementDelimiters to VOID
set windowString to string(gScriptOMaticWindow)
set startPos to offset(QUOTE, string(windowString)) + 1
set windowNameString to char startPos to length(windowString) - 2 of windowString
if windowPresent(windowNameString) then
forget(gScriptOMaticWindow)
set gScriptOMaticWindow to VOID
else
set gScriptOMaticWindow to VOID
halt()
end if
end
on checkForBetaExpiration
end
on stopMovie
closeScriptOMatic()
end
on displayDemoOverAlert
alert(the title of gScriptOMaticWindow && "only allows a total of 20 scripts to be formatted per session." & RETURN & "Call g/matter, inc. at +1-415-243-0394 or email <sales@gmatter.com> to purchase a full feature version of ScriptOMatic Xtra!")
closeScriptOMatic()
end
on keyDown
if the key = RETURN then
formatCurrentScript()
end if
end
on resizeSOMWindow windowLayoutSymbol
set currentRect to the rect of gScriptOMaticWindow
set wLeft to the left of currentRect
set wTop to the top of currentRect
case windowLayoutSymbol of
#outprev:
set newRect to rect(wLeft, wTop, wLeft + 576, wTop + 340)
go("outprev")
#outnoprev:
set newRect to rect(wLeft, wTop, wLeft + 576, wTop + 210)
go("outnoprev")
#in:
set newRect to rect(wLeft, wTop, wLeft + 288, wTop + 210)
go("in")
end case
set the rect of gScriptOMaticWindow to newRect
end
on zoomWindow
set gScriptOMaticZoomOut to not gScriptOMaticZoomOut
case gScriptOMaticZoomOut of
1:
case gScriptOMaticPreview of
1:
resizeSOMWindow(#outprev)
0:
resizeSOMWindow(#outnoprev)
end case
0:
resizeSOMWindow(#in)
end case
end
on resetFormats
set gScriptOMaticCurrentFormatTable to duplicate(gScriptOMaticDefaultFormatTable)
set totalElements to count(gScriptOMaticDefaultFormatTable)
repeat with elementIndex = 1 to 9
set elementSymbol to getPropAt(gScriptOMaticDefaultFormatTable, elementIndex)
set elementData to getaProp(gScriptOMaticDefaultFormatTable, elementSymbol)
set the hilite of member ("activate" & string(the id of elementData)) to the activate of elementData
setDisplayText(member ("color" & string(the id of elementData)), string(the Color of elementData))
setFont(member ("color" & string(the id of elementData)), popMenuFont())
setFontSize(member ("color" & string(the id of elementData)), popMenuFontSize())
setDisplayText(member ("style" & string(the id of elementData)), string(the style of elementData))
setFont(member ("style" & string(the id of elementData)), popMenuFont())
setFontSize(member ("style" & string(the id of elementData)), popMenuFontSize())
setMenuField(member ("face" & string(the id of elementData)), member "TextFace")
setDisplayText(member ("face" & string(the id of elementData)), string(the face of elementData))
setFont(member ("face" & string(the id of elementData)), popMenuFont())
setFontSize(member ("face" & string(the id of elementData)), popMenuFontSize())
setDisplayText(member ("size" & string(the id of elementData)), string(the size of elementData))
setFont(member ("size" & string(the id of elementData)), popMenuFont())
setFontSize(member ("size" & string(the id of elementData)), popMenuFontSize())
end repeat
end
on popMenuFontSize
if the platform starts "M" then
return 9
else
return 12
end if
end
on popMenuFont
if the platform starts "M" then
return "Geneva"
else
return "Arial"
end if
end
on formatCurrentScript
if gScriptOMaticDemo and (gScriptOMaticUsageCount >= 20) then
displayDemoOverAlert()
else
cursor(4)
if gScriptOMaticDebug then
set now to the ticks
end if
set handlerNamelist to findAllHandlers()
tell the stage
set currentCastLib to the activeCastLib
set selectionList to the selection of castLib currentCastLib
end tell
if count(selectionList) > 0 then
set currentMember to getAt(getAt(selectionList, 1), 1)
tell the stage
set memberType to the type of member currentMember of castLib currentCastLib
end tell
if memberType <> #empty then
tell the stage
set scriptText to the scriptText of member currentMember of castLib currentCastLib
end tell
if (scriptText <> EMPTY) and (scriptText <> RETURN) and (scriptText <> " ") then
set gScriptOMaticObject to new(script "ScriptFormatter", currentMember, currentCastLib, scriptText, handlerNamelist)
parseScript(gScriptOMaticObject)
formatScript(gScriptOMaticObject)
if gScriptOMaticDemo then
set gScriptOMaticUsageCount to gScriptOMaticUsageCount + 1
end if
cursor(-1)
else
alert("The current castmember is either not a script or does not have a cast script attached.")
end if
if gScriptOMaticDebug then
set endTicks to the ticks - now
put "Formatted the current script in", endTicks, "ticks"
end if
else
alert("The currently selected castmember in the stage movie is empty.")
end if
else
alert("There are no castmembers selected in the stage movie.")
end if
cursor(-1)
end if
end
on formatAllScripts
if gScriptOMaticDemo and (gScriptOMaticUsageCount >= 20) then
displayDemoOverAlert()
else
cursor(4)
if gScriptOMaticDebug then
set now to the ticks
end if
set handlerNamelist to findAllHandlers()
set totalFormatted to 0
tell the stage
set totalCastLibs to the number of castLibs
end tell
repeat with theCastLib = 1 to totalCastLibs
tell the stage
set totalMembers to the number of castMembers of castLib theCastLib
end tell
repeat with theMember = 1 to totalMembers
tell the stage
set scriptText to the scriptText of member theMember of castLib theCastLib
end tell
if (scriptText <> EMPTY) and (scriptText <> RETURN) and (scriptText <> " ") then
set totalFormatted to totalFormatted + 1
set gScriptOMaticObject to new(script "ScriptFormatter", theMember, theCastLib, scriptText, handlerNamelist)
parseScript(gScriptOMaticObject)
formatScript(gScriptOMaticObject)
if gScriptOMaticDebug then
set endTicks to the ticks - now
end if
if gScriptOMaticDemo and (totalFormatted >= 5) then
alert(the title of gScriptOMaticWindow && "only allows formatting of the first 5 scripts found." & RETURN & "Call g/matter, inc. at +1-415-243-0394 or email <sales@gmatter.com> to purchase a full feature version of ScriptOMatic Xtra!")
set theCastLib to totalCastLibs + 1
exit repeat
end if
end if
end repeat
end repeat
cursor(-1)
if gScriptOMaticDemo then
set gScriptOMaticUsageCount to gScriptOMaticUsageCount + 1
end if
if totalFormatted = 0 then
alert("Sorry, but no scripts were found in your stage movie.")
else
if gScriptOMaticDebug then
put "formatted", totalFormatted, "scripts in", endTicks, "ticks"
end if
if gScriptOMaticDebug then
put "average time was", endTicks / float(totalFormatted), "ticks"
end if
end if
end if
end
on elements string, elementNum
set totalChars to length(string)
set elementList to []
set element to EMPTY
repeat with theChar = 1 to totalChars
set aChar to char theChar of string
if gScriptOMaticElementDelimiters contains aChar then
if element <> EMPTY then
add(elementList, element)
set element to EMPTY
end if
next repeat
end if
put aChar after element
end repeat
if element <> EMPTY then
add(elementList, element)
end if
if not voidp(elementNum) then
return getAt(elementList, elementNum)
else
return elementList
end if
end
on elementsData string, elementNum
set totalChars to length(string)
set elementList to [:]
set element to EMPTY
set elementLoc to 1
set waitingForNewElement to 1
repeat with theChar = 1 to totalChars
set aChar to char theChar of string
if gScriptOMaticElementDelimiters contains aChar then
if element <> EMPTY then
addProp(elementList, element, elementLoc)
set element to EMPTY
set waitingForNewElement to 1
end if
next repeat
end if
if waitingForNewElement then
set waitingForNewElement to 0
set elementLoc to theChar
end if
put aChar after element
end repeat
if element <> EMPTY then
addProp(elementList, element, elementLoc)
end if
if not voidp(elementNum) then
return getAt(elementList, elementNum)
else
return elementList
end if
end
on eTest
set testString to "tell the stage to put (the scriptText of member currentMember of castLib the activeCastlib <> EMPTY) into scriptAvailable"
startTimer()
repeat with X = 1 to 200
set r to elementsData(testString)
end repeat
put the timer
end
on displayAboutBox
if the shiftDown then
alert("Special thanks to Karyn Schussler, Joshua Bryan Schussler (my *other* new product), Jonathan Grayson, Mike Edmunds, Anders Wallgren, Diana Wynne, John C. Ware, Leesa Lee, Jim Corbett, Carrie Myers, Doug Wyrick, Mike Seery, Bill Schulze and Shan Franklin.")
else
if the optionDown then
alert("This is only a demo. Were this an actual product, you would see flying chrome logos and piecharts and hear dancing boys and trombones. But this is only a demo.")
else
alert(the title of gScriptOMaticWindow && "version" && gScriptOMaticVersion & RETURN & "Copyright © 1997 by g/matter, inc." & RETURN & "All Rights Reserved." & RETURN & RETURN & "ScriptColor Xtra component engineered by Glenn Picher, Dirigo Multimedia." & RETURN & the title of gScriptOMaticWindow && "designed and engineered by Terry R. Schussler.")
end if
end if
end
on findAllHandlers
if gScriptOMaticDebug then
set now to the ticks
end if
set handlerNamelist to []
sort(handlerNamelist)
tell the stage
set totalCastLibs to the number of castLibs
end tell
repeat with theCastLib = 1 to totalCastLibs
tell the stage
set totalMembers to the number of castMembers of castLib theCastLib
end tell
repeat with theMember = 1 to totalMembers
tell the stage
set memberType to the type of member theMember of castLib theCastLib
end tell
if memberType = #script then
tell the stage
set memberScriptType to the scriptType of member theMember of castLib theCastLib
end tell
if memberScriptType = #movie then
tell the stage
set scriptText to the scriptText of member theMember of castLib theCastLib
end tell
if scriptText <> EMPTY then
set totalLines to the number of lines in scriptText
repeat with theLine = 1 to totalLines
if word 1 of line 1 of scriptText = "on" then
add(handlerNamelist, symbol(word 2 of line 1 of scriptText))
end if
delete line 1 of scriptText
end repeat
end if
end if
end if
end repeat
end repeat
if gScriptOMaticDebug then
set endTicks to the ticks - now
end if
if gScriptOMaticDebug then
put "Found all the handlers in", endTicks, "ticks"